exports.controllers={
	admin_market_vendors: function(space) {
		if (!space.roles.marketconfig) return "-";
		var mode=space.fields.mode||"list";
		switch (mode) {
			case "list":
				space.items=space.mfact.list("market_vendor",{order_by: "ordering"});
				return space.views.process("widgets/market_vendors/admin_"+mode,space);
				break;
			case "edit":
				space.item={};
				if (space.fields.id) space.item=space.mfact.get("market_vendor",space.fields.id);
				return space.views.process("widgets/market_vendors/admin_"+mode,space);
				break;
			case "save":
				var item;
				if (space.fields.id) {
					item=space.mfact.get("market_vendor",space.fields.id);
					item.UpdateFromObject(space.fields);
				} else {
					item=space.mfact.from_object("market_vendor",space.fields);
				}
				item.Save();
				return JSON.stringify({redirect:{url: space.action}});
				break;
			case "delete":
				space.item=space.mfact.get("market_vendor",space.fields.id);
				return space.views.process("widgets/market_vendors/admin_"+mode,space);
				break;
			case "delete_save":
				space.mfact.get("market_vendor",space.fields.id).Delete();
				return JSON.stringify({redirect:{url: space.action}});
				break;
			case "reorder":
				space.functions.reorder_grids(space,"_models/market_vendor/");
				return JSON.stringify({});
				break;
		} 
	}
};

